import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        String str = "null";
        Scanner inPut = new Scanner(System.in);
        while (true){
            System.out.println("输入字符串:");
            str = inPut.nextLine();
            if (str.equals("end")){
                break;
            }
            int count = 0;
            for (int i = 0; i < str.length(); i++) {
                if(str.charAt(i) == ' ' && str.charAt(i + 1) != ' '){
                    count++;
                }
            }
            System.out.println("共有单词:" + (count + 1) + "个。");
        }
    }

    public static void main0(String[] args) {
        String a = "null";
        while (true){
            Scanner inPut = new Scanner(System.in);
            System.out.println("请输入字符串:(输入end表示退出程序)");
            a = inPut.nextLine();
            if (a.equals("end")){
                break;
            }
            System.out.println(a.toLowerCase());
        }
    }
}